//git目录下新建index.js
const child_process = require("child_process");
//定义一个执行cmd的函数

const time = new Date().toLocaleString();

const cmd = 'git pull && git add . && git commit -m "'+time+'" && git push origin master';
const cmdStr = cmd.toString();
console.log(cmdStr);
function exec(cmdStr){
    return new Promise(function(resolve,reject){
        child_process.exec(cmdStr,function(err,stdout,stderr){
            if(err){
                reject(err);
            }else{
                resolve(stdout);
            }
        });
    });
}
//执行cmd命令
exec(cmdStr).then(function(stdout){
    console.log(stdout);
}).catch(function(err){
    console.log(err);
});
